{extend name="common:base" /}
{block name="title"}系统安装Step2{/block}
{block name="nav"}
<li ><span class="am-text-success cxx-install-num"><i class="am-icon-check am-text-lg"></i></span><span class="cxx-install-text">安装协议</span></li>
<li><span class="am-text-success cxx-install-num"><i class="am-icon-check am-text-lg"></i></span><span class="cxx-install-text">环境检测</span></li>
<li><span class="am-text-success cxx-install-num"><i class="am-icon-info am-text-secondary am-text-lg"></i></span><span class="cxx-install-text">参数设置</span></li>
<li><span class="cxx-install-num">4</span><span class="cxx-install-text">开始安装</span></li>
<li><span class="cxx-install-num">5</span><span class="cxx-install-text">安装完成</span></li>
{/block}
{block name="content"}
<div class="am-padding">
    <div class="am-text-left">
        <form name="formSetup" id="formSetup" action="{:url('step4')}" method="post"  class="am-form">
            	<div class="option am-text-default am-text-center">系统数据库配置</div>
                <div class="am-form-group am-hide">
                <div><label>数据库类型</label></div>
                <label class="css-input css-radio css-radio-warning push-10-r">
                    <input type="radio" name="db[type]" checked="" value="mysql"><span style="color:#777">MySQL</span> 
                </label>
            	</div>
                <div class="am-form-group">
                <label>数据库服务器，数据库服务器IP，<span class="am-text-danger">一般为127.0.0.1</span></label>
                <input  type="text" name="db[hostname]" value="" placeholder="一般为127.0.0.1">
                </div>
                <div class="am-form-group">
                <label>数据库名</label>
                <input class="am-form-field am-radius" type="text" name="db[database]" value="" placeholder="请输入数据库名称">
                </div>
                <div class="am-form-group" style="display:none;" id='cover' >
                <div><label class="am-text-danger">是否覆盖同名数据库</label></div>
                    <label class="am-checkbox am-success"><input name="cover" type="checkbox" value="1" data-am-ucheck="" class="am-ucheck-checkbox">
                        <span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span> 覆盖
                    </label>             
                </div>
                <div class="am-form-group">
                <label>数据库用户名</label>
                <input class="am-form-field am-radius" type="text" name="db[username]" value="" placeholder="请输入数据库用户名">
				
                </div>
                <div class="am-form-group">
                <label>数据库密码</label>
                <input class="am-form-field am-radius" type="text" name="db[password]" value="" placeholder="请输入数据库密码">
                </div>
                <div class="am-form-group">
                <label>数据库端口，数据库服务连接端口，<span class="am-text-danger">一般为3306</span></label>
                <input class="am-form-field am-radius" type="text" name="db[hostport]" value="3306" placeholder="3306" placeholder="请输入数据库端口">
                </div>
                <div class="am-form-group" style="display:none;>
                <label>数据表前缀，<span class="am-text-danger">保持默认</span></label>
                <input class="am-form-field am-radius" type="text" name="db[prefix]" value="cxxia_" placeholder="请输入数据表前缀" >
				</div>
                <div class="am-form-group">
				
            	<div class="option am-text-default am-text-center">管理员账号配置</div>
                <label>管理员账号：</label>
                <input class="am-form-field am-radius" type="text" name="admin[username]" value="" placeholder="请输入管理员账号">
                </div>
                <div class="am-form-group">
                <label>管理员密码：</label>
                <input class="am-form-field am-radius" type="text" name="admin[password]" value="" placeholder="请输入管理员密码，明文注意！">
				</div>
                <div class="am-text-center am-margin-top-lg">
                <a id='step3' href="javascript::vod(0)"  class="am-btn am-btn-success  am-radius" >下一步</a>
                <a href="{$Request.baseFile}?s=/install/index/step2.html" class="am-btn am-btn-primary  am-radius">上一步</a>
                </div>
        </form>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
$(function (){
	$('#step3').click(
        function(){
			
            collect_url =  "{$Request.baseFile}?s=/install/index/step4.html";
            document.formSetup.action = collect_url;
            document.formSetup.method = 'post';
            $.ajax({
                type: "POST",
                url: collect_url,
                dataType: "json",
                data: $("#formSetup").serialize(),
                success: complete,
                
            });
            
            function complete(result){
                if(result.code == 1){
                   layer.msg(result.msg, {icon: 1, time: 3000}); 
				   location.href = "{$Request.baseFile}?s=/install/index/step4.html";
                } else {
					if(result.msg == '该数据库已存在'){
						$('#cover').show();
					}
                    layer.msg(result.msg, {icon: 2, time: 5000});   
                    
                }
            }  
             
 	});   
});   
</script>
{/block}